#include <system.h>
#include <Affichage.h>
#include "Lib\altera_up_avalon_vga\sdk\alt_up_vga.h"

int clear_screen()
{
  int i, j;
  
  /*On passe tous les catactere de l'ecran VGA*/
  for(i = 0; i < ALT_UP_VGA_PIX_X_RESOLUTION; i++)
  {
    for(j = 0; j < ALT_UP_VGA_PIX_Y_RESOLUTION; j++)
    {
      ecritchaine(i, j, " ");
    }
  }
  return 1;
}

void ecritchaine(unsigned int start_x, unsigned int start_y, unsigned char *ptr)
{  
  /*On inscrit a l'ecran tous les caractere de la string jusqu'au NULL*/
  while(*ptr)
  {
    alt_up_vga_draw_char_1b(*ptr, start_x++, start_y);
    *ptr++;
  }
}

void dessine_carre(int start_x, int start_y, int width, int height)
{
  int i, j;
  
  for(i = start_x; i <= start_x + width; i++)
  {
    ecritchaine(i, start_y, SQUARE_CHAR);
  }  
  for(i = start_x; i <= start_x + width; i++)
  {
    ecritchaine(i, start_y + height, SQUARE_CHAR);
  }  
  for(j = start_y; j < start_y + height; j++)
  {
     ecritchaine(start_x, j, SQUARE_CHAR);
  }
  for(j = start_y; j < start_y + height; j++)
  {
     ecritchaine(start_x + width, j, SQUARE_CHAR);
  }
}

int afficher_vga()
{
  clear_screen();
  
  dessine_carre(10, 10, 23, 8);
  
  ecritchaine(16, 9, "ENVIRONNEMENT");
  ecritchaine(12, 12, "Temperature: 32dg");
  ecritchaine(12, 14, "Humidite: 60%");
  ecritchaine(12, 16, "Ensoleillement: 75%");
  
  
return 1;
}

 